package com.lucenly.card.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.lucenly.card.R;

public class LianxiDialog extends Dialog{
    public LianxiDialog(@NonNull Context context,String name,String url) {
        super(context, R.style.alert_dialog);
        setContentView(R.layout.dialog_lianxi);
        TextView tv_wxName = findViewById(R.id.tv_wxName);
        SimpleDraweeView iv_img = findViewById(R.id.iv_img);
        TextView tv_sure = findViewById(R.id.tv_sure);
        tv_wxName.setText("添加微信:"+name);
        iv_img.setImageURI(url);
        tv_sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        initView(context);
    }

    private void initView(Context context) {
        LinearLayout lLayout_bg = (LinearLayout) findViewById(R.id.lLayout_bg);
        WindowManager windowManager = (WindowManager) context
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        setCanceledOnTouchOutside(false);
        // 调整dialog背景大小
        lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display
                .getWidth() * 0.8), LinearLayout.LayoutParams.WRAP_CONTENT));
        setCanceledOnTouchOutside(true);
    }
}
